home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / c / pcw.zip / MENUDEMO.C < prev    next >
C/C++ Source or Header  |  1991-10-16  |  7KB  |  179 lines

  1. /**********************************************************/
  2. /* File Id.                  Menudemo.C                   */
  3. /* Author.                   Stan Milam.                  */
  4. /* Date Written.             05/30/89.                    */
  5. /*                                                        */
  6. /* Comments:  A little demonstration of PC Windows, and   */
  7. /* more specifically the menus.                           */
  8. /*                                                        */
  9. /* Be sure to link with PDEMO.C & LDEMO.C.                */
  10. /* Examples:                                              */
  11. /*   mslink menudemo.c ldemo.c pdemo.c (Microsoft C)      */
  12. /*   tclink menudemo ldemo pdemo       (Turbo C)          */
  13. /*   pc /e  menudemo                   (Power C .prj file)*/
  14. /**********************************************************/
  15.  
  16. #include <stdio.h>
  17. #include "pcwproto.h"
  18. #include "menu.h"
  19.  
  20. extern int CheckSnow;
  21.  
  22. /* First lets do a few window messages.... */
  23.  
  24. static char *intromsg[] = {
  25.    "PC Windows!  PCW is a windowing package written in C for C",
  26.    "using the IBM family of personal  computers and  100% true",
  27.    "compatibles.  PCW supports Microsoft C 5.0+, Turbo C 1.5+,",
  28.    "and MIX POWER C 1.1.6+. PCW not only supports windows.....",
  29.    "it features automatic sensing of the adapter & monitor  in",
  30.    "use.  It also does  QUICK  screen  writes (NO SNOW ON CGA)",
  31.    "with functions like qprintf() & qputs(). Also featured are",
  32.    "popup menus & a variation of the famous  Lotus  menu  with",
  33.    "MOUSE support.  In short, PCW gives  you  control  and all",
  34.    "the video power you can use.  Best of all, PCW is targeted",
  35.    "as SHAREWARE software!  Press a key and let's take a look.",
  36.    NULL
  37. };
  38.  
  39. static char *menumsg[] = {
  40.    "I've prepared a little demo for you.  Let's take a look at",
  41.    "the menus.  I feature the menus because  they  demonstrate",
  42.    "many of the capabilities of PCW.  In fact, the menu  func-",
  43.    "tions were built using  functions already  in  PCW. So, if",
  44.    "you are ready make a selection from the pick list and lets",
  45.    "Take a look                                               ",
  46.    " ",
  47.    "P.S.  I scrolled the window VERY SLOWLY so you could see it",
  48.    "happen!                                                    ",
  49.    NULL
  50. };
  51.  
  52. static char *goodby[] = {
  53.    "Well, I have labored long and hard to bring you PC Windows",
  54.    "and I hope you enjoy it.  After much thought and consider-",
  55.    "ation I have decided to let PCW be FREEWARE so enjoy!!!!  ",
  56.    NULL
  57. };
  58.  
  59. static char *copyright[] = {
  60.    "PC Windows",
  61.    "(c) Copyright 1989, 1990",
  62.    "by",
  63.    "Stan Milam",
  64.    NULL
  65. };
  66.  
  67. static char *selections[] = {
  68.    "Pop Up Menu",
  69.    "Light Bar Menu",
  70.    "Pick List Menu",
  71.    "Exit",
  72.    NULL
  73. };
  74.  
  75. static PICKLIST pl_menu = {
  76.     NULL,
  77.     18,30,23,50,
  78.     BLUE, LIGHTGRAY,
  79.     DOUBLEALL, RED, LIGHTGRAY,
  80.     " Pick Menu ",
  81.     TOP, MIDDLE, BLACK, LIGHTGRAY,
  82.     WHITE, BLUE,
  83.     selections, 0, 0
  84. };
  85.  
  86. /* Some function Prototypes. */
  87.  
  88. int  lmenu_demo(void);
  89. int  pmenu_demo(void);
  90. int  pl_menu_demo (void);
  91. void scrollit(WNDPTR *wnd, int count);
  92.  
  93. int (*option[3])(void) = {
  94.     pmenu_demo,
  95.     lmenu_demo,
  96.     pl_menu_demo
  97. };
  98.  
  99.  
  100. /*******************************/
  101. /*             MAIN            */
  102. /*******************************/
  103. int main(void) {
  104.  
  105.    int mtype, select;
  106.    int mxr, mxc, tl, bl;               /* Max rows & cols */
  107.    WNDPTR *savewnd, *msgwnd, *pwnd;     /* Save screen & message window */
  108.  
  109.    if (!chk_video_state(&mxr, &mxc)) return(3);/* Check-get max rows & cols */
  110.    get_cursor_size(&tl,&bl);
  111.    set_cursor_size(0,0);
  112.    savewnd = wpush(1,1,mxr,mxc);               /* Save entire screen */
  113.    if (!savewnd) return(3);                    /* Exit if we cannot */
  114.    qfill(1,1,mxr,mxc,LIGHTGRAY,BLUE,176);      /* Fill scrn with funy chars */
  115.    bordercolor(BLACK,LIGHTGRAY);               /* Set border color */
  116.    titlecolor(RED,LIGHTGRAY);                  /* Set the title */
  117.    msgwnd = wexplode(2,8,16,72,BLUE,LIGHTGRAY);/* Frame the message window */
  118.    if (!msgwnd) {                              /* And bug out if failed */
  119.       savewnd = wpop(savewnd);
  120.       scroll(1,1,mxr,mxc,7,0,10);
  121.       qputs(mxr,CENTER,RED,BLACK,"Not enough memory for PCW!");
  122.       swait(10);
  123.       return(3);
  124.     }
  125.     wtitle(msgwnd,TOP,MIDDLE," PC Windows Menu Demo "); /* Do the title */
  126.     w_block_write(msgwnd,2,CENTER,intromsg);            /* Put the 1st msg */
  127.     keywait(60);
  128.     scrollit(msgwnd, 13);                               /* Scroll it down */
  129.     set_wnd_attr(msgwnd, BLACK,LIGHTGRAY);              /* Chg wnd colors */
  130.     w_block_write(msgwnd,2,CENTER,menumsg);             /* Put 2nd message */
  131.     init_mouse();                                       /* Initialize mouse */
  132.     if (mpresent) {                                     /* Is rat home? */
  133.        hide_mouse();                                    /* Out of sight */
  134.        mtype = MK_ATTR(YELLOW+BLINK,BLACK) | 4;         /* Mouse cursor */
  135.        set_mtype(0,0,mtype);                            /* Set rat cursor */
  136.     }
  137.     pwnd = make_pick_list( &pl_menu );
  138.     for (select = 0;select > -1 && select < 3;) {
  139.         select = get_pick_list( &pl_menu );
  140.         if ( select == -1 || select == 3 ) continue;
  141.         if (mpresent) hide_mouse();
  142.         whide(msgwnd);
  143.         whide(pwnd);
  144.         if ((*option[select])()) {
  145.            msgwnd = wpop(msgwnd);                  /* Bug out if error */
  146.            savewnd= wpop(savewnd);
  147.            vcls();
  148.            puts("Error while performing menu demo");
  149.            swait(10);
  150.            return(3);
  151.         }
  152.         wshow(pwnd);
  153.         wshow(msgwnd);
  154.     }
  155.     if (mpresent) hide_mouse();                /* If rat is home hide it */
  156.     wpop( pwnd ); swait(1);
  157.     scrollit(msgwnd,13);                       /* Scroll it down 5 lines */
  158.     set_wnd_attr(msgwnd,YELLOW,LIGHTGRAY);     /* Change the window color */
  159.     w_block_write(msgwnd,2,CENTER,goodby);     /* Say good-bye sweetheart! */
  160.     keywait(10);                               /* Wait 10 seconds */
  161.     savewnd = wpop(savewnd);                   /* Remove background chars */
  162.     set_wnd_attr(msgwnd,BLUE,LIGHTGRAY);       /* Change its color to blue */
  163.     w_block_write(msgwnd,7, CENTER, copyright);/* Write Copyright */
  164.     keywait(5);                                /* Let them see it */
  165.     msgwnd  = wpop(msgwnd);                    /* Remove the window */
  166.     set_cursor_size(tl, bl);                   /* Restore the cursor */
  167.     return(0);                                 /* Good-night Irene! */
  168. }
  169.  
  170. void scrollit(WNDPTR *wnd, int count) {
  171.  
  172.    int lcv;
  173.  
  174.    for (lcv = 0; lcv < count; lcv++) {
  175.       wscroll(wnd,1,1);                        /* Scroll wnd down 1 line */
  176.       if (_adaptor != CGA) rest(1);            /* Slow down fast monitors */
  177.    }
  178. }
  179.